﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Mammoth.Entities;
using Mammoth.Services;
using Mammoth.ViewModels;

namespace Mammoth.Views.Message
{
    /// <summary>
    /// Interaction logic for MessageList.xaml
    /// </summary>
    public partial class MessageList : UserControl
    {
        public GTalkMessageType MessageType
        {
            get { return (GTalkMessageType)GetValue(MessageTypeProperty); }
            set { SetValue(MessageTypeProperty, value); }
        }

        public static readonly DependencyProperty MessageTypeProperty =
            DependencyProperty.Register("MessageType", typeof(GTalkMessageType), typeof(MessageList), 
            new PropertyMetadata(GTalkMessageType.Inbox));

        public MessageList(IViewModelFactory vmFactory)
        {
            InitializeComponent();
            var d = App.Current.Windows.OfType<MainWindow>().First();
            WPFViewModelBase vm;
            if(MessageType == GTalkMessageType.Inbox)
                vm = vmFactory.GetViewModel<MessageViewModel<InboxEntity>>(d);
            else
                vm = vmFactory.GetViewModel<MessageViewModel<OutboxEntity>>(d);
            DataContext = vm;
        }
    }
}
